package com.sjzsqjy.asdtiang.db;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.sjzsqjy.asdtiang.mysql.Doctor;
import com.sjzsqjy.asdtiang.mysql.ItemSet;
import com.sjzsqjy.asdtiang.mysql.SampleType;
import com.sjzsqjy.asdtiang.mysql.ShiQiaoUser;
import com.sjzsqjy.asdtiang.mysql.TraceType;
import com.sjzsqjy.asdtiang.mysql.TraceUser;

public class SearchService extends HibernateDaoSupport{
	private static SearchService searchService;
	public static SearchService getSearchService(){
		if(null==searchService){
			searchService=new SearchService();
		}
		return searchService;
	}
	/////思桥数据查询
	public List shiQiaoUserSearch(String date, String name) {
		String[] values = new String[] { date,name };
		List ls = getHibernateTemplate().findByNamedQuery("shiQiaoUserSearch", values);
		return ls.size() != 0 ? ls: null;
	}
	public ShiQiaoUser shiQiaoUserSearch1(String date, String sampleId) {
		String[] values = new String[] { date,sampleId };
		List ls = getHibernateTemplate().findByNamedQuery("shiQiaoUserSearch1", values);
		return ls.size() != 0 ? (ShiQiaoUser)ls.get(0): null;
	}
	public List shiQiaoResult(String date, String sampleId) {
		String[] values = new String[] { date,sampleId };
		List ls = getHibernateTemplate().findByNamedQuery("shiQiaoResult", values);
		return ls.size() != 0 ? ls: null;
	}
	public Doctor doctor(String id) {
		String[] values = new String[] { id };
		List ls = getHibernateTemplate().findByNamedQuery("doctor", values);
		return ls.size() != 0 ?(Doctor)ls.get(0):null;
	}
	public ItemSet itemSet(String code) {
		String[] values = new String[] { code};
		List ls = getHibernateTemplate().findByNamedQuery("itemSet", values);
		return ls.size() != 0 ?(ItemSet)ls.get(0):null;
	}
	/////样品数据查询
	public List sampleUser(String name,String date){
		String[] values = new String[] {"%"+name+"%" ,"%"+date+"%" };
		List ls = getHibernateTemplate().findByNamedQuery("sampleUser", values);
		return ls.size() != 0 ? ls: null;
	}
	public List sampleResultList(String sampleId){
		String[] values = new String[] {sampleId };
		List ls = getHibernateTemplate().findByNamedQuery("sampleResultList", values);
		return ls.size() != 0 ? ls: null;
	}
	public List sampleResultCharList(String sampleId){
		String[] values = new String[] {sampleId };
		List ls = getHibernateTemplate().findByNamedQuery("sampleResultCharList", values);
		return ls.size() != 0 ? ls: null;
	}
	public SampleType sampleType(String name){
		String[] values = new String[] { name};
		List ls = getHibernateTemplate().findByNamedQuery("sampleType", values);
		return ls.size() != 0 ?(SampleType)ls.get(0):null;
	}
	public SampleType getSampleTypeByItem(String item){
		String[] values = new String[] { item};
		List ls = getHibernateTemplate().findByNamedQuery("getSampleTypeByItem", values);
		return ls.size() != 0 ?(SampleType)ls.get(0):null;
	}
	//////微量元素检测
	public List traceUser(String name,String date){
		String[] values = new String[] {name ,date};
		List ls = getHibernateTemplate().findByNamedQuery("traceUser", values);
		return ls.size() != 0 ? ls: null;
		
	}
	
	public TraceUser getTraceUserById(String id){
		String[] values = new String[] {id};
		List ls = getHibernateTemplate().findByNamedQuery("getTraceUserById", values);
		return ls.size() != 0 ?(TraceUser)ls.get(0):null;
	}
	////
	public List getTraceUserListByUserId(String userId){
		String[] values = new String[] {userId};
		List ls = getHibernateTemplate().findByNamedQuery("getTraceUserListByUserId", values);
		return ls.size() != 0 ? ls: null;
		
	}
	public TraceType getTraceTypeByName(String name){
		String[] values = new String[] {name};
		List ls = getHibernateTemplate().findByNamedQuery("getTraceTypeByName", values);
		return ls.size() != 0 ?(TraceType)ls.get(0):null;
	}
	
}
